/*
 * @Author: ztao
 * @Date: 2021-09-22 09:21:56
 * @LastEditTime: 2022-01-17 16:37:28
 * @Description: cookie不能用了 因为后端限制http-only(默认就是true,前端改不了)
 */
// import Cookies from 'js-cookie'

class Cookies {
  set(TokenKey = 'SESSION', token) {
    return sessionStorage.setItem(TokenKey, token)
  }
  get(TokenKey = 'SESSION') {
    return sessionStorage.getItem(TokenKey)
  }
  remove(TokenKey = 'SESSION') {
    return sessionStorage.removeItem(TokenKey)
  }
  static getInstance() {
    if (!Cookies.instance) {
      Cookies.instance = new Cookies()
    }
    return Cookies.instance
  }
}

const cookies = Cookies.getInstance()
export function getToken(TokenKey = 'SESSION') {
  return cookies.get(TokenKey)
}

export function setToken(token, TokenKey = 'SESSION') {
  return cookies.set(TokenKey, token)
}

export function removeToken(TokenKey = 'SESSION') {
  return cookies.remove(TokenKey)
}
